<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<label id="l1">get<br/></label><br/>
		<label id="l2">post<br/></label>
	</body>
	<script type="text/javascript">
		onload = function() {
			g1(),g2(),g3(),g4(),g5();
			p1(), p2(),p3();
		}

		function p1() {
			var ajax = new XMLHttpRequest();
			ajax.open('POST', 'https://api.apiopen.top/getImages');
			ajax.send('page=0&count=2');
			ajax.onreadystatechange = function() {
				if (ajax.status == 200 && ajax.readyState == 4) {
					var obj = JSON.parse(ajax.responseText);
					var l2obj = document.getElementById('l2');
					l2obj.innerHTML += obj.result[19].id + obj.result[19].time + `<img src=` + obj.result[19].img + ` >` + `<br/>`;
					console.log(obj);
				}
			}
		}

		function p2() {
			var ajax = new XMLHttpRequest();
			ajax.open('POST', 'https://api.apiopen.top/getSongPoetry');
			ajax.send('page=1&count=2');
			ajax.onreadystatechange = function() {
				if (ajax.status == 200 && ajax.readyState == 4) {
					var obj = JSON.parse(ajax.responseText);
					var l2obj = document.getElementById('l2');
						l2obj.innerHTML +=obj.result+`<br/>`;
					console.log(obj);
				}
			}
		}
		function p3() {
			var ajax = new XMLHttpRequest();
			ajax.open('POST', 'https://api.apiopen.top/getJoke');
			ajax.send('type=all&page=1&count=10');
			ajax.onreadystatechange = function() {
				if (ajax.status == 200 && ajax.readyState == 4) {
					var obj = JSON.parse(ajax.responseText);
					var l2obj = document.getElementById('l2');
						l2obj.innerHTML +=obj.result[0].sid+':'+obj.result[0].text+`<br/>`;
					console.log(obj);
				}
			}
		}
		function g1() {
			var ajax = new XMLHttpRequest();
			ajax.open('GET', 'http://poetry.apiopen.top/getTime')
			ajax.send();
			ajax.onreadystatechange = function() {
				if (ajax.status == 200 && ajax.readyState == 4) {
					var obj = JSON.parse(ajax.responseText);
					var l1obj = document.getElementById('l1');
					l1obj.innerHTML += obj.result.date +`/`+obj.result.time +`/`+ obj.result.weekday + `<br/>`;
					console.log(obj.result)
				}
			}
		}

		function g2() {
			var ajax = new XMLHttpRequest();
			ajax.open('GET', 'http://poetry.apiopen.top/sentences')
			ajax.send();
			ajax.onreadystatechange = function() {
				if (ajax.status == 200 && ajax.readyState == 4) {
					var l1obj = document.getElementById('l1');
					var obj = JSON.parse(ajax.responseText);
					l1obj.innerHTML += obj.result.name +`——`+ obj.result.from + `<br/>`;
					console.log(ajax.responseText);
					console.log(obj.result);
				}
			}
		}

		function g3() {
			var ajax = new XMLHttpRequest();
			ajax.open('GET', 'http://poetry.apiopen.top/poetryFull?count=2&page=1')
			ajax.send();
			ajax.onreadystatechange = function() {
				if (ajax.status == 200 && ajax.readyState == 4) {
					var l1obj = document.getElementById('l1');
					var obj = JSON.parse(ajax.responseText);
					l1obj.innerHTML += obj.result[0].title+`<br/>`+obj.result[0].dynasty+obj.result[0].writer+`<br/>`+obj.result[0].content+ `<br/>`+
					 obj.result[1].title+`<br/>`+obj.result[1].dynasty+obj.result[1].writer+`<br/>`+obj.result[1].content+ `<br/>`;
					console.log(ajax.responseText);
					console.log(obj.result);
				}
			}
		}

		function g4() {
			var ajax = new XMLHttpRequest();
			ajax.open('GET', 'http://poetry.apiopen.top/poetryAuthor?count=2&page=1&name=李白')
			ajax.send();
			ajax.onreadystatechange = function() {
				if (ajax.status == 200 && ajax.readyState == 4) {
					var l1obj = document.getElementById('l1');
					var obj = JSON.parse(ajax.responseText);
					l1obj.innerHTML += obj.result.name +`<br/>`+obj.result.simpleIntro+`<br/>`+obj.result.detailIntro + `<br/>`;
					console.log(ajax.responseText);
					console.log(obj.result);
				}
			}
		}

		function g5() {
			var ajax = new XMLHttpRequest();
			ajax.open('GET', 'http://poetry.apiopen.top/poetry?count=2&page=1')
			ajax.send();
			ajax.onreadystatechange = function() {
				if (ajax.status == 200 && ajax.readyState == 4) {
					var l1obj = document.getElementById('l1');
					var obj = JSON.parse(ajax.responseText);
					l1obj.innerHTML += obj.result[0].title+`<br/>`+obj.result[0].dynasty+obj.result[0].writer+`<br/>`+obj.result[0].content+ `<br/>`+
					 obj.result[1].title+`<br/>`+obj.result[1].dynasty+obj.result[1].writer+`<br/>`+obj.result[1].content+ `<br/>`;
					console.log(ajax.responseText);
					console.log(obj.result);
				}
			}
		}
	</script>
</html>
